/*
 * =====================================================================================
 *
 *       Filename:  test.cc
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2009年12月11日 16时36分05秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  lerosua (), lerosua@gmail.com
 *        Company:  cyclone
 *
 * =====================================================================================
 */

#include <string>
#include <iostream>

using namespace std;

string getUrl(const string & input)
{
	size_t pos ;
	pos = input.find("http://");
	if(pos != std::string::npos){
		string header = input.substr(pos,std::string::npos);
		pos = header.find(" ");
		if(pos != std::string::npos)
			return header.substr(0,pos);
		else
			return header;
	}
	else
		return "";

}
int main(int argc, char *argv[])
{

	string str_text="my blog is http://lerosua.org welcome to access here";
	string str2    ="my blog is http://lerosua.cn/blog";
	string rc;
	rc = getUrl(str_text);
	cout<<"get url "<<rc<<endl;
	rc = getUrl(str2);
	cout<<"get url "<<rc<<endl;

	printf("\n");
	return 0;
}

